var Timeout = function(func, millisec) {
	this.func = func;
	this.stTime = new Date().valueOf();
	this.timeout = setTimeout(func, millisec);
	this.timeLeft = millisec;
	this.originalTimeLeft = millisec;
};
(function() {
	var timeout_pause = function() {
		clearTimeout(this.timeout);
		var timeRan = new Date().valueOf()-this.stTime;
		this.timeLeft -= timeRan;
	};
	var timeout_unpause = function() {
		this.timeout = setTimeout(this.func, this.timeLeft);
		this.stTime = new Date().valueOf();
	};
	var timeout_reset = function(millisec) {
		this.pause();
		if ( millisec ) {
			this.timeLeft = millisec;
		} else {
			this.timeLeft = this.originalTimeLeft;
		}
		this.unpause();
	};
	var timeout_left = function() {
		var time_left = this.timeLeft - (new Date().valueOf()-this.stTime);
		return time_left;
	};
	Timeout.prototype.pause   = timeout_pause;
	Timeout.prototype.unpause = timeout_unpause;
	Timeout.prototype.reset   = timeout_reset;
	Timeout.prototype.left    = timeout_left;
})();